﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<VCC.CMS.ViewModels.UserIndexCmsViewModel>" %>
<%@ Import Namespace="VCC.Lib.Helpers" %>
<%@ Import Namespace="VCC.Lib.Paging" %>
<%@ Import Namespace="VCC.CMS.Controllers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Quản lý User
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if(ViewData["MessageInfo"]==null){ %>
	<form action="/User/IndexCms" method="post" name="adminForm">
		<table width="100%">
			<tr>
			    <td align="left">
			        Tìm nhanh <%= Html.TextBox("Keyword", Model.Keyword) %>
			        <%= Html.ActionImageJS("Tìm kiếm", "icon-32-search.png", "document.adminForm.submit();", false)%>
			    </td>
				<td align="right">
				    <%=Html.DropDownList("ActiveYN", new SelectList(Model.ListActiveYN, "Key", "Value", Model.ActiveYN).ToList(), "--Trạng thái kích hoạt --", new { onchange = "document.adminForm.submit();" })%>				    
				    <%=Html.DropDownList("OperationYN", new SelectList(Model.ListOperation, "Key", "Value", Model.OperationYN).ToList(), "--Trạng thái hoạt động --", new { onchange = "document.adminForm.submit();" })%>		
			    </td>
			</tr>
		</table>
		<table width="100%" class="adminlist">
		    <thead>
			<tr>
				<th width="30" align="right">
					STT
				</th>
				<th align ="center">
					 <%= Html.Sort("Có " +Model.Users.TotalItemCount +" user trong danh sách", "UserName", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th>
				    Địa chỉ
				</th>
				<th width="80">
					 <%= Html.Sort("Ngày đăng ký", "CreatedDate", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th width="80" align ="center">
				    Kích hoạt
				</th>
				<th width="80" align ="center">
				    Hoạt động
				</th>
				<th style="width: 40px">
                    <%= Html.Sort("ID", "ID", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
                </th>
			</tr>
			</thead>
			<tbody>
		<% 
			int i = 0;
    		foreach (var item in Model.Users) {
				i++;
		%>
			<tr id="tr_<%=item.ID%>">
				<td align="right">
					<%= i.ToString() %>
				</td>
				<td>
				    <div>
                        <div class="aditem">
                            <div class="imageAvatar">
                                <a href="#"><img width="60" height="55" src="<%=VCC.Lib.Common.LinkUtils.AvataOrDefault(item.AvataPath)%>" title="" alt="" /></a>
                            </div>
                            <div class="summary">
                                    Tên đăng nhập:<%=Html.Encode(item.UserName)%><br />
                                    Họ tên:<%=item.DisplayName%><br />
                                    Tỉnh thành: <%=item.City!= null ? item.City.Name : "Không xác định"%><br />
                                    <span class="contactInfo">Giới tính:<span class="lightLale"><%=Html.Encode(item.Sexual == true ? "Nam" : "Nữ")%></span>
                                    SĐT:<span class="lightLale"><%=Html.Encode(item.Phone)%></span>
                                      Email:<span class="lightLale"><%=Html.Encode(item.Email)%></span>
                                      <span class="lightLale" style="margin-left:5px">Lần truy cập cuối:<%= item.LastLogInTime!= null ? string.Format("{0:dd/MM/yyyy H:mm}",item.LastLogInTime.Value) : ""%></span>
                                      </span>
                            </div>
                        </div>
                    </div>
				</td>
				<td>
				    <%=item.Address%>
				</td>
				<td align="center">
				    <%= string.Format("{0:dd/MM/yyyy HH:mm}",item.CreatedDate)%>
				</td>
				<td align="center">
                    <img alt="" id="activeYN_<%= item.ID %>" onclick="ChangePubYN(<%= item.ID %>);" value="<%= item.ActiveYN.HasValue ? item.ActiveYN.Value : false %>"
                        src="<%= item.ActiveYN.HasValue && item.ActiveYN.Value==true ? "/Images/icon-32-apply.png" : "/Images/icon-32-cancel.png" %>" />
                </td>
                <td align="center">
                    <img alt="" id="operationYN_<%= item.ID %>" onclick="ChangeOperationYN(<%= item.ID %>);" value="<%= item.OperationYN.HasValue ? item.OperationYN.Value : false %>"
                        src="<%= item.OperationYN.HasValue && item.OperationYN.Value==true ? "/Images/icon-32-apply.png" : "/Images/icon-32-cancel.png" %>" />
                </td>
				<td align="center">
				    <%=Html.Encode(item.ID) %>
				</td>
			</tr>
		<% } %>
        </tbody>
		</table>
		<%= Html.Hidden("order")%>
		<%= Html.Hidden("orderDir")%>
		<table width="100%">
            <tr>
                <td align="center">
             
                <div class="pager">
                <label>Hiển thị #</label>
                    <%
                        int[] pageSizeList = {1, 5, 10, 15, 20, 25, 50, 100};
                    %>
                    <%= Html.DropDownList("PageSize", new SelectList(pageSizeList, Model.Users.PageSize), new { onchange = "document.adminForm.submit();" })%>

                    <%= Html.Pager(Model.Users.PageSize, Model.Users.PageNumber, Model.Users.TotalItemCount)%>
                </div>
                </td>
            </tr>
        </table>
	</form>
 <% } %>
  <script type="text/javascript">
        function ChangePubYN(id) {
            var obj = $("#activeYN_" + id);
            ApplyChangeYN("/Applications/ApplyChangeYN/ApChangeYN/" + "User" + '/' + "ActiveYN" + '/' + id + '/' + obj.attr("value"), id, obj);
        }
        function ChangeOperationYN(id) {
            var obj = $("#operationYN_" + id);
            ApplyChangeYN("/Applications/ApplyChangeYN/ApChangeYN/" + "User" + '/' + "OperationYN" + '/' + id + '/' + obj.attr("value"), id, obj);
        }
    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
Danh sách thành viên
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
<%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>  
</asp:Content>
